﻿#pragma once
#ifndef INPUTHANDLER_H
#define INPUTHANDLER_H

#include <QObject>
#include <QPushButton>


//这个类负责处理所有按钮点击事件，并发送信号给控制器

class InputHandler : public QObject {
    Q_OBJECT
public:

    explicit InputHandler(QObject* parent = nullptr);

    ~InputHandler() {};

    //绑定所有按钮，将其映射到不同信号
    void attachButtons(const QList<QPushButton*>& buttons);

signals:
    //数字键
    void digitButtonPressed(QChar digit);

    //运算符键
    void operatorButtonPressed(QChar op);

    //括号键
    void parenthesisButtonPressed(QChar paren);

    //小数点键
    void pointButtonPressed(QChar paren);

    //清除当前输入
    void clearEntryButtonPressed();

    //清空键
    void clearButtonPressed();

    //返回键
    void backButtonPressed();

    //前进键
    void forwardButtonPressed();

    //删除键
    void deleteButtonPressed();

    //取反键
    void negateButtonPressed();

    //等号键
    void equalButtonPressed();

    //倒数 1/x
    void inverseButtonPressed();

    //平方 x²
    void squareButtonPressed();

    //开方 √
    void sqrtButtonPressed();

    //百分号 %
    void percentButtonPressed();

};

#endif 
